#include<cstdio>
#include<cmath>
#include<cstring>
int n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	if(r/n>l/n){
		printf("%d",n-1);
	}
	else{
		if(r%n>l%n){
			printf("%d",r%n);
		}
		else{
			printf("%d",l%n);
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
